package com.allen.study.application.api.assembler;

import com.allen.study.application.api.assembler.mapper.IApprovalRecordDTOStructMapper;
import com.allen.study.application.api.request.ApprovalRecordCreateRequest;
import com.allen.study.application.api.request.ApprovalRecordQueryRequest;
import com.allen.study.application.api.request.ApprovalRecordUpdateRequest;
import com.allen.study.application.api.response.ApprovalRecordQueryResponse;
import com.allen.study.application.api.response.ApprovalRecordResponse;
import com.allen.study.domain.entity.ApprovalRecord;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 审批记录表类型转换器
 *
 * @author AllenSun
 * @since 2025-04-23 20:46
 */
@Component
public class ApprovalRecordDTOAssembler {

    /**
     * 审批记录表创建请求数据传输对象 转 审批记录表实体
     *
     * @param createRequest 审批记录表创建请求数据传输对象
     * @return 审批记录表实体
     */
    public ApprovalRecord assembler(ApprovalRecordCreateRequest createRequest) {
        //领域模型 自行实现 entity组装工厂类 (domian层提供)
        return IApprovalRecordDTOStructMapper.INSTANCE.fromCreateRequest(createRequest);
    }

    /**
     * 审批记录表更新请求数据传输对象 转 审批记录表实体
     *
     * @param updateRequest 审批记录表更新请求数据传输对象
     * @return 审批记录表实体
     */
    public ApprovalRecord assembler(ApprovalRecordUpdateRequest updateRequest) {
        //领域模型 自行实现 entity组装工厂类 (domian层提供)
        return IApprovalRecordDTOStructMapper.INSTANCE.fromUpdateRequest(updateRequest);
    }

    /**
     * 审批记录表查询请求数据传输对象 转 审批记录表实体
     *
     * @param queryRequest 审批记录表查询请求数据传输对象
     * @return 审批记录表实体
     */
    public ApprovalRecord assembler(ApprovalRecordQueryRequest queryRequest) {
        //领域模型 自行实现 entity组装工厂类 (domian层提供)
        return IApprovalRecordDTOStructMapper.INSTANCE.fromQueryRequest(queryRequest);
    }

    /**
     * 审批记录表实体 转 审批记录表响应数据传输对象
     *
     * @param approvalRecord 审批记录表实体
     * @return 审批记录表响应数据传输对象
     */
    public ApprovalRecordResponse toResponse(ApprovalRecord approvalRecord) {
        return IApprovalRecordDTOStructMapper.INSTANCE.toResponse(approvalRecord);
    }

    /**
     * 审批记录表实体 转 审批记录表查询响应数据传输对象
     *
     * @param approvalRecord 审批记录表实体
     * @return 审批记录表查询响应数据传输对象
     */
    public ApprovalRecordQueryResponse toQueryResponse(ApprovalRecord approvalRecord) {
        return IApprovalRecordDTOStructMapper.INSTANCE.toQueryResponse(approvalRecord);
    }

    /**
     * 审批记录表实体列表 转 审批记录表查询响应数据传输对象列表
     *
     * @param approvalRecordList 审批记录表实体列表
     * @return 审批记录表查询响应数据传输对象列表
     */
    public List<ApprovalRecordQueryResponse> toQueryResponse(List<ApprovalRecord> approvalRecordList) {
        return IApprovalRecordDTOStructMapper.INSTANCE.toQueryResponse(approvalRecordList);
    }
}
